package com.kehutong.flow.admin;

import org.coraframework.authz.HasPermission;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.Bean;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.Result;
import org.coraframework.orm.jdbc.JdbcSession;

import com.kehutong.common.util.Token;
import com.kehutong.flow.entity.FlowOffer;
import com.kehutong.flow.service.FlowOfferService;

@MvcAction
@ReqMapping("/admin/flow/offer")
public class FlowOfferController {
	
	@Inject
	private JdbcSession signJDBCSession;

    @Inject
    private FlowOfferService flowOfferService;

    @HasPermission("flow:offer:view")
    @ReqMapping("/list")
    public Object list(JSONObject jsonObject) {
    	return Result.success(flowOfferService.list(jsonObject));
    }

    @HasPermission("flow:offer:view")
    @ReqMapping("/get")
    public Object get(String id) {
        return Result.success(flowOfferService.get(id));
    }

    @Bean(newInstance=true, copy=true)
    @HasPermission("flow:offer:edit")
    @ReqMapping("/save")
    public Object save(FlowOffer item) {
        return flowOfferService.save(item);
    }

    @Bean(copy=true)
    @HasPermission("flow:offer:edit")
    @ReqMapping("/update")
    public Object update(FlowOffer item) {
        return flowOfferService.update(item);
    }

    @HasPermission("flow:offer:edit")
    @ReqMapping("/delete")
    public Object delete(String id) {
        return flowOfferService.delete(id);
    }

//    @HasPermission("flow:offer:get")
    @ReqMapping("/getEmp")
    public Object getEmp(JSONObject jsonObject, Token token) throws Exception {
        return flowOfferService.getEmp(jsonObject, token);
    }
}
